package org.eclipse.stp.policy_builder;

import java.util.ArrayList;
import java.util.Iterator;

import org.eclipse.stp.policy_builder.model.source.ParameterMap;
import org.eclipse.stp.policy_builder.model.source.SourceExtensionParser;
import org.eclipse.stp.policy_builder.model.source.SourceParameter;
import org.eclipse.stp.policy_builder.model.source.SourceType;
import org.eclipse.stp.policy_builder.util.PolicyBuilderLog;

public class Test {
	
	public static void testRun(){
		SourceExtensionParser<SourceType> parser = new SourceExtensionParser<SourceType>(Activator.PLUGIN_ID,"source");
		ArrayList<SourceType> temp = parser.run();
		for(SourceType sType : temp ){
			String desc = sType.getDescription();
			String className = sType.getClassName() ;
			String name = sType.getName() ;
			
			PolicyBuilderLog.logInfo("Extension : " + "[name :" + name +"] " + "[class :" + className +"] " + "[description :" + desc +"] ");
			printMap(sType.getParameterContainer(),name);
		}
		
	}
	
	public static void printMap(ParameterMap map,String extName){
		Iterator<String> it = map.getKeySet();
		while(it.hasNext()){
			String key = it.next();
			SourceParameter param = map.getValue(key);
			PolicyBuilderLog.logInfo("Ext : " + extName + "parameters :");
			PolicyBuilderLog.logInfo("Param Key : " + key);
			printParameter(param);
		}
		
	}
	
	public static void printParameter(SourceParameter p){
		PolicyBuilderLog.logInfo("Param Type : " +p.getParameterType());
		PolicyBuilderLog.logInfo("Param Value : " +p.getParameterValue());

	}
	
}
